package demo06;

public class Demo02Polymiorphism {
    public static void main(String[] args) {
        Cat cat=new Cat();
        Dog dog=new Dog();
//        Animal animal=new Cat();
//        Animal animal1=new Dog();

        //对比可以发现多态的写法更加简洁和灵活
        showCatEat(cat);
        showDogEat(dog);
        System.out.println("==================");
        showAnimaiEat(cat);
        showAnimaiEat(dog);
    }

    public static void showCatEat(Cat cat){
        cat.eat();
    }

    public static void showDogEat(Dog dog){
        dog.eat();
    }
    public static void showAnimaiEat(Animal animal){
        animal.eat();
    }
}
